<template>
    <div class="order-detail">
        <div class="card">
            <div class="goods">
                <img :src="getOtherImageUrl(goods_img)">
                <div class=" detail">
                    <span class="title bold">{{ detailData.goods_name }}</span>
                    <span class="package f14 grey">套餐:{{ detailData.setmeal_name }}</span>
                    <span class="time f14 grey">{{ detailData.lease_time }}</span>
                    <div class="all-price">
                        <span class="f14">总租金:￥{{ detailData.total_num }}(共一期)</span>
                        <span class="number f14 grey">x1</span>
                    </div>
                </div>
            </div>
            <div class="price">
                <div class="item">
                    <span class="val">{{ detailData.first_rent }}</span>
                    <span class="text f12 grey">首期租金(元)</span>
                </div>
                <div class="item">
                    <span class="val">{{ detailData.total_rent }}</span>
                    <span class="text f12 grey">总租金(元)</span>
                </div>
                <div class="item">
                    <span class="val">{{ detailData.goods_price }}</span>
                    <span class="text f12 grey">商品总价值(元)</span>
                </div>
            </div>
        </div>
        <div class="stages">
            <div class="head">
                <span>分期方式</span>
                <div class="right">
                    <span class="grey f14">1个月租期间隔</span>
                    <img @click="showTips = true" src="@/assets/images/bangzhu.png">
                </div>
            </div>
            <div class="content">
                <div class="list">
                    <div class="item bg">
                        <span>期数</span>
                        <span>租期</span>
                        <span>每期租金</span>
                    </div>
                    <div class="item grey" v-for="(item, index) in detailData.order_lease" :key="index">
                        <span>{{ item.which_period }}</span>
                        <span>{{ item.lease_term }}</span>
                        <span>{{ item.lease_price }}元</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="back">
            <div class="btn" @click="back">
                返回
            </div>
        </div>
        <div class="show-tips" v-show="showTips" @click="showTips = false">
            <div class="box" @click.stop>
                <div class="close-btn" @click.stop="showTips = false">
                    <Close></Close>
                </div>
                <div class="title">
                    <span>分期方式</span>
                </div>
                <span class="text f12">1.您当前选中的套餐租期为自定义租期商品，每期租赁周期为1个月,到租赁结束时间为止。</span>
                <span class="text f12">2.扣款日为每期开始租赁时间。</span>
            </div>
        </div>
    </div>
</template>
<script>
import Close from "@/components/Close.vue"
export default {
    name: "",
    components: {
        Close
    },
    data() {
        return {
            detailData: {},
            showTips: false,
            goods_img: "",
        }
    },
    created() {
        this.getData();
    },
    methods: {
        getData() {
            const query = this.$route.query;
            this.goods_img = query.goods_img;
            delete query.goods_img;
            this.$sendPost("Order/getOrderLeaseTerm", query)
                .then(res => {
                    if (res.data.status === 200) {
                        const { data } = res.data;
                        this.detailData = data;
                    }
                })
        },
        back() {
            this.$router.back();
        }
    }
}
</script>
<style lang="scss" scoped>
.grey {
    color: #939393;
}

.order-detail {
    padding-bottom: 65px;

    .card {
        padding: 15px 10px;

        .goods {
            background-color: white;
            display: flex;
            padding-bottom: 10px;
            border-bottom: 1px solid #cdcdcd;

            img {
                height: 140px;
                width: 140px;
            }

            .detail {
                width: 215px;
                padding: 10px 0;
                display: flex;
                flex-direction: column;

                .package {
                    margin-top: 5px;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                }

                .time {
                    margin: 5px 0;
                }

                .all-price {
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                }
            }
        }

        .price {
            display: flex;
            padding: 10px 0;

            .item {
                width: 33.333%;
                display: flex;
                flex-direction: column;
                align-items: center;
            }
        }
    }

    .stages {
        padding: 15px;
        background-color: #f7f7f7;

        .head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            background-color: white;
            padding: 15px;
            border-bottom: 1px solid #cdcdcd;

            .right {
                display: flex;
                align-items: center;

                img {
                    margin-left: 10px;
                    height: 18px;
                    object-fit: contain;
                }
            }
        }

        .content {
            padding: 15px;
            background-color: white;

            .list {
                border: 1px solid #cdcdcd;

                .bg {
                    background-color: #f6f6f6;
                }

                .item {
                    display: flex;

                    &:last-of-type {
                        span {
                            border-bottom: 0;
                        }
                    }

                    span {
                        padding: 7px 0;
                        display: inline-block;
                        text-align: center;
                        font-size: 14px;
                        border-bottom: 1px solid #cdcdcd;

                        &:nth-of-type(1) {
                            flex-basis: 17%;
                        }

                        &:nth-of-type(2) {
                            flex-basis: 57%;
                            border-left: 1px solid #cdcdcd;
                        }

                        &:nth-of-type(3) {
                            flex-basis: 25%;
                            border-left: 1px solid #cdcdcd;
                        }
                    }
                }
            }
        }
    }

    .back {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        padding: 10px;
        border-top: 1px solid #cecece;
        background-color: #ffffff;
        height: 65px;

        .btn {
            width: 100%;
            height: 45px;
            border-radius: 20px;
            text-align: center;
            line-height: 45px;
            color: white;
            background-image: linear-gradient(to right, #f6635c, #ef291e);
        }
    }

    .show-tips {
        width: 100vw;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        background-color: rgba(0, 0, 0, .2);
        display: flex;
        align-items: center;
        justify-content: center;

        .box {
            background-color: white;
            width: 300px;
            border-radius: 10px;
            padding: 20px 10px 30px;
            position: relative;

            .close-btn {
                position: absolute;
                right: 15px;
                top: 15px;
            }

            .title {
                text-align: center;
                font-size: 20px;
                font-weight: bold;
            }

            .text {
                color: #bfbfbf;

                &:nth-of-type(1) {
                    margin-top: 20px;
                    margin-bottom: 25px;
                }
            }
        }
    }
}
</style>